home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-30 | 3.8 KB | 90 lines | [TEXT/ToyS] |
- copy the version of application "UltraFind 2.2" to currentVersion
- if currentVersion is less than "2.1.3" then
- display dialog "To run this script you must have UltraFind version 2.1.3 or greater" & return & return & ┬
- "The version of UltraFind you are running is only " & currentVersion buttons "Cancel"
- else
- set numFiles to 0
- tell application "UltraFind 2.2"
- clear
-
- set the text of fileName of its searchRoutine to "read me"
- set the searchType of fileName of its searchRoutine to nameIs
-
- set the text of targetWord 1 of searchText of its searchRoutine to "apple"
- set the text of targetWord 2 of searchText of its searchRoutine to "version"
- set the text of targetWord 3 of searchText of its searchRoutine to "project"
-
- --the following scripts are commented out and are included only as examples:
-
- -- example of how to use UltraFind's Thesaurus:
- -- set the XRef of targetWord 1 of searchText of its searchRoutine to XRefON
-
- -- use this to find only those files which contain both target words:
- -- set options of searchText of its searchRoutine to matchAll
-
- -- use this only if you want to search ALL types of files (including graphics images, application, etc.
- -- without this only documents likely to contain text will be searched:
- -- set options of searchText of its searchRoutine to searchAll
-
- -- use this only if you want to search the files' resource forks:
- -- set options of searchText of its searchRoutine to searchResources
-
- -- you may want to search only those files in a specific directory, e.g.:
- -- set the confineDirectory of its searchRoutine to "Hard Disk:Text Files"
-
- --set the maximum number of found words to show, e.g. 3
- set showWords of searchText of its searchRoutine to 1
-
- scan
- changeView finderView --make sure the list window is in FINDER VIEW to process the text found
- copy the result to numFiles
- end tell
-
- if numFiles is greater than 0 then
-
- --process the list in TEXT VIEW to get individual words and offsets
- tell application "UltraFind 2.2" to changeView textView
- copy the result to numRecords
- set recNum to 1
- set fileNum to 1
- set dialogtext to ""
- repeat until recNum is greater than numRecords
-
- tell application "UltraFind 2.2"
- copy (the fileName of fileRecord recNum) to fName
- copy (the textFound of fileRecord recNum) to fText
- copy (the textOffset of fileRecord recNum) to fOffset
- end tell
- set recNum to recNum + 1
-
- --in TEXT view each file found has one MASTER record and one or more TEXT records
- --the MASTER record returns a list of all the words found but has no textoffset
- --the TEXT record returns the words found and its location (textoffset) in characters from the start of the file
- if fOffset is equal to "" then --its a master record
- --check if previous file's results dialog needs to be displayed
- if dialogtext is not equal to "" then
- set dialogtext to dialogtext & return
- display dialog dialogtext buttons {"Cancel", "Next"} default button 2
- end if
- set dialogtext to "Found file " & (fileNum as text) & " of " & (numFiles as text) & return & return & ┬
- "Text Search Results for File '" & fName & "' :" & return & return
- set fileNum to fileNum + 1
- else
- set dialogtext to dialogtext & "At offset " & fOffset & " found '" & fText & "'" & return
- end if
- end repeat
-
- --repeat with fileNum from 1 to numFiles
- -- tell application "UltraFind 2.1"
- -- copy (the fileName of fileRecord fileNum) to fName
- -- copy (the textFound of fileRecord fileNum) to fText
- -- end tell
-
- -- display dialog "Found file " & (fileNum as text) & " of " & (numFiles as text) & return & return & ┬
- -- "Filename : " & fName & return & ┬
- -- "Found words: '" & fText & "'" & return & return ┬
- -- buttons {"Cancel", "Next"} default button 2
- --end repeat
-
- end if
- end if